package persistencia;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

import entidades.Cor;
import persistencia.util.HibernateUtil;

public class CorDAO extends HibernateDAO<Cor>{


		
	public List<Cor> getTodasAsCores() {
		return HibernateUtil.getSession().createCriteria(Cor.class).list();
	}

	public List<Cor> getCorPelaCor(String cor) {
		Criteria criteria = HibernateUtil.getSession()
				.createCriteria(Cor.class);
		// criteria.add(Restrictions.eq("nome", nome));
		criteria.add(Restrictions.like("cor", "%" + cor + "%"));
		return criteria.list();
	}

	public Cor getCorPeloId(Integer key) {
		return (Cor) HibernateUtil.getSession().get(Cor.class, key);
	}

}
